<template>
  <el-dialog
    @close="close"
    v-bind="$attrs"
    custom-class="cool-dialog"
    ref="dialogRef"
    :draggable="!notDraggable"
    :close-on-click-modal="closeOnClickModal"
  >
    <img
      @click="close"
      src="@/assets/images/dialog-close.png"
      style="
        width: 48px;
        height: 48px;
        position: absolute;
        top: -16px;
        right: -16px;
        cursor: pointer;
      "
    />
    <div
      class="pitch-mixin"
      data-augmented-ui="tl-2-clip-y t-clip-x tr-scoop bl-2-clip-x br-clip-x both"
      style="
        width: 100%;
        min-height: 120px;
        height: 100%;
        padding: 20px 40px 40px 40px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
      "
    >
      <p
        style="
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          margin-bottom: 20px;
          font-size: var(--el-dialog-title-font-size);
          line-height: 24px;
        "
      >
        {{ title }}
      </p>
      <div>
        <slot />
      </div>
      <div class="customized el-dialog__footer">
        <slot name="footer" />
      </div>
    </div>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

interface IProps {
  title?: string
  notDraggable?: boolean
  closeOnClickModal?: boolean
}

withDefaults(defineProps<IProps>(), {
  notDraggable: false,
  closeOnClickModal: false,
})

const dialogRef = ref()

const emit = defineEmits(['update:modelValue', 'close'])

const close = () => {
  emit('update:modelValue', false)
  emit('close')
}
</script>

<style lang="scss">
.cool-dialog {
  // important是临时方案
  background: transparent !important;
  position: relative;
  box-shadow: none;

  //.el-dialog__title {
  //    color: white;
  //}
  //
  //.el-dialog__headerbtn .el-dialog__close {
  //    color: white;
  //}
  .el-dialog__header {
    width: calc(100% - 100px);
    position: absolute;
    z-index: 9999;
    height: 32px;

    * {
      display: none;
    }
  }

  .customized.el-dialog__footer {
    display: unset;
    padding: 20px 0 10px 0;
  }

  .el-dialog__body {
    background: transparent;
    color: white;
    padding: 0;
  }

  .pitch-mixin {
    padding: 20px 40px !important;
    --aug-tr: 40px;
    --aug-t-extend1: 40%;

    --aug-border-all: 3px;
    --aug-border-bg: #09a4f0;

    --aug-inlay-all: 4px;
    --aug-inlay-bg: #00071f;
    --aug-inlay-opacity: 0.8;
  }
}
</style>
